home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 23 / hdsentry.zip / HDSENTRY.ASM next >
Assembly Source File  |  1987-05-28  |  7KB  |  131 lines

  1. ;----------------------------------------------------------------------------:
  2. ;       HARD DISK SENTRY - FIXED DISK PROTECTION AGAINST TROJAN PROGRAMS     :
  3. ;                     Copyright 1987 by Andrew M. Fried                      :
  4. ;                                                                            :
  5. ;  HDSENTRY is the copyrighted property of its author.  You are free to use  :
  6. ;  this program without charge with my compliments.  This program may freely :
  7. ;  distributed so long as the following limitations are adheared to:         :
  8. ;     o  No charge is made for its distribution                              :
  9. ;     o  The product is distributed in unmodified form                       :
  10. ;     o  Documentation accompanies the program                               :
  11. ;     o  The authors copyright notice is left in the program                 :
  12. ;     o  No portion of this program is included into any commercial package  :
  13. ;        without written consent of the author                               :
  14. ;                                                                            :
  15. ;     Andrew M. Fried                                                        :
  16. ;     895 Cynthia Drive                                                      :
  17. ;     Titusville, Fla. 32780                                                 :
  18. ;     (305) 268-4500                                                         :
  19. ;                                                                            :
  20. ;----------------------------------------------------------------------------:
  21.  
  22. page 60,132
  23. TITLE TITLE - HARD DISK SENTRY DISK PROTECTION UTILITY
  24.  
  25. cseg segment byte public
  26.  
  27. Public  maincode, go, copyright, alert_msg, old_13, old_26, install, tsr
  28. Public  sentry, which_disk, ok, abort, dummy, init, show_copr, get_int_13
  29. Public  set_int_13, set_int_26
  30.  
  31. maincode      proc far
  32.               assume  cs:cseg
  33.               org 100h                 ; used to create a com program
  34.  
  35. go:           jmp  install
  36. copyright     db   13,10
  37.               db   '╔═══════════════════════════════════════════╗',13,10
  38.               db   '║           HARD DISK SENTRY 1.01           ║',13,10
  39.               db   '║   (c) Copyright 1987 by Andrew M. Fried   ║',13,10
  40.               db   '╚═══════════════════════════════════════════╝',13,10
  41.               db   '    NO DESTRUCTIVE CALLS TO THE FIXED DISK',13,10
  42.               db   '             WILL BE PERMITTED.',13,10,'$'
  43. alert_msg     db   13,10,07,'<<< ALERT >>>  Destructive disk call prevented!$'
  44. old_13        dd   0                   ; address of original interrupt 13h
  45. old_26        dd   0                   ; address of original interrupt 26h
  46. install:      call init                ; initialize system
  47. tsr:          lea  dx,init             ; boundary of program
  48.               mov  cx,4                ; shift count used for division
  49.               shr  dx,cl               ; transform from bytes to paragraphs
  50.               inc  dx                  ; add an extra paragraph for stragglers
  51.               mov  ax,3100h            ; terminate & remain resident dos call
  52.               int  21h                 ; ask dos to terminate & stay resident
  53. maincode      endp
  54.  
  55.  
  56.  
  57. ;----------------------------------------------------------------------------
  58. ; This is the main guts of the program.  Anytime a disk service is requested,
  59. ; this interrupt handler will be called.  It acts much like a filter.  Any
  60. ; calls involving the floppy disk are merely passed on to the original
  61. ; interrupt handler.  If a call is made which points to a fixed disk, however,
  62. ; it is checked.  If the call is destructive (write or format), the handler
  63. ; prevents it from occuring.  Simple but quite effective.
  64. ;----------------------------------------------------------------------------
  65.  
  66. sentry        proc
  67. which_disk:   cmp  dl,80h              ; are we working on the hard disk???
  68.               jb   ok                  ; if not, simply continue on
  69.               cmp  ah,3                ; is it a write command??
  70.               je   abort               ;   if so, abort
  71.               cmp  ah,5                ; is it a format command??
  72.               je   abort               ;   if so, abort
  73.               cmp  ah,0Bh              ; is it an extended fd command??
  74.               je   abort               ;   if so, abort
  75. ok:           jmp  dword ptr [old_13]  ; go back into original handler
  76. abort:        push ax                  ; save registers
  77.               push dx
  78.               push ds
  79.               mov  ah,9                ; dos print string function request
  80.               push cs                  ; insure ds = cs
  81.               pop  ds
  82.               lea  dx,alert_msg        ; require ds:dx string addressing
  83.               int  21h                 ; call dos to print string
  84.               pop  ds                  ; restore registers
  85.               pop  dx
  86.               pop  ax
  87.               sub  ah,ah               ; show no error code return
  88.               iret                     ; return to calling process
  89. sentry        endp
  90.  
  91.  
  92.  
  93. ;----------------------------------------------------------------------------
  94. ; This procedure becomes the 'new' interrupt 26h handler.  As you can see,
  95. ; when an application program makes this call they don't get much chance to
  96. ; do any damage.
  97. ;----------------------------------------------------------------------------
  98.  
  99. dummy         proc
  100.               sub ax,ax                ; zero out the dx register
  101.               push ax                  ; place extra word on stack
  102.               iret                     ; return to caller with stack modified
  103. dummy         endp
  104.  
  105.  
  106.  
  107. ;----------------------------------------------------------------------------
  108. ; This procedure sets the interrupt vectors and displays the copyright notice
  109. ; (which I ask that you leave undisturbed)
  110. ;----------------------------------------------------------------------------
  111.  
  112. init          proc                     ; main initialization routine
  113. show_copr:    mov  ah,9                ; dos print string function request
  114.               lea  dx,copyright        ; require ds:dx string addressing
  115.               int  21h                 ; call dos to print string
  116. get_int_13:   mov  ax,3513h            ; get hard disk interrupt vector
  117.               int  21h                 ; use dos function call
  118.               mov  word ptr old_13,bx  ; store offset
  119.               mov  word ptr old_13[2],es; store segment
  120. set_int_13:   mov  ax,2513h            ; make int 13 point to our handler
  121.               lea  dx,sentry           ; get address of interrupt routine
  122.               int  21h                 ; call dos to set new vector
  123. set_int_26:   mov  ax,2526h            ; make int 26 point to our handler
  124.               lea  dx,dummy            ; get address of interrupt routine
  125.               int  21h                 ; call dos to set new vector
  126.               ret                      ; installation is done
  127. init          endp
  128. ;----------------------------------------------------------------------------
  129. cseg          ends
  130.               end  go
  131.